﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

using Core.Localization;
using Core.Localization.Attributes;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;

namespace Core.Logic.Options
{
	[DataContract]
    [LocalizableDisplayName("RAE", "Strings", "Options")]
    public class Options : ICloneable
	{
		[DataMember]
		[LocalizableDisplayName("RAE", "Strings", "Language")]
		[LocalizableCategory("RAE", "Strings", "General")]
        public Language Language { get; set; }

		[DataMember]
		[LocalizableDisplayName("RAE", "Strings", "Models_сatalog")]
		[LocalizableCategory("RAE", "Strings", "General")]
        public string ModelsCatalog { get; set; }

		[DataMember]
		[LocalizableDisplayName("RAE", "Strings", "Keywords")]
		[LocalizableCategory("RAE", "Strings", "Models")]
		public List<string> Keywords { get; set; }

		[DataMember]
		[LocalizableDisplayName("RAE", "Strings", "Id_autogeneration")]
		[LocalizableCategory("RAE", "Strings", "Models")]
		public bool IdAutogeneration { get; set; }

		[DataMember]
		[LocalizableDisplayName("RAE", "Strings", "Font")]
		[LocalizableCategory("RAE", "Strings", "Export")]
		[ItemsSource(typeof(FontNamesItemsSource))]
		public string Font { get; set; }

		public bool IsModified = false;

		public static Options CreateDefaultOptions(LocalizationManager localizationManager)
        {
	        var keywords = new List<string>(11)
		                       {
			                       localizationManager.Localize("RAE:Strings:Not"),
			                       localizationManager.Localize("RAE:Strings:More"),
			                       localizationManager.Localize("RAE:Strings:Less"),
			                       localizationManager.Localize("RAE:Strings:As_well_as"),
			                       localizationManager.Localize("RAE:Strings:Part"),
			                       localizationManager.Localize("RAE:Strings:Substitution"),
			                       localizationManager.Localize("RAE:Strings:Other_then"),
			                       localizationManager.Localize("RAE:Strings:Early"),
			                       localizationManager.Localize("RAE:Strings:Late"),
			                       localizationManager.Localize("RAE:Strings:Before"),
			                       localizationManager.Localize("RAE:Strings:After")
		                       };

			return new Options
            {
                Language = Language.English,
                ModelsCatalog = ".",
				Keywords = keywords,
				IdAutogeneration = true,
				Font = "Calibry"
            };
        }

        public Options Clone()
        {
            return new Options
            {
                Language = Language,
				ModelsCatalog = ModelsCatalog,
				Keywords = Keywords,
				IdAutogeneration = IdAutogeneration,
				Font = Font,
                IsModified = IsModified
            };
        }

        #region ICloneable implementation

        object ICloneable.Clone()
        {
            return Clone();
        }

        #endregion
    }
}